// ------------------------------------------------------------------------------------------------------------------------
// Plemiona.pl 5.X Skrypt użytkowy
//
// Nazwa:      Kolorator podobnych raportów i wiadomości
// Wersja:     2.0
// Autor:      Lukasz032 (Plemiona Ś7)
// Dostosował: Lukasz032 (Plemiona Ś7)
//
// Tagi specjakne:
// Licencja:   Creative Commons Uznanie autorstwa - Brak komercyjnego zastosowania - Na tych samych warunkach 2.0 Polska
// Informacje: http://creativecommons.org/licenses/by-nc-sa/2.0/pl
// Support:    lvwnbrz@lykamspam.pl
//
// ------------------------------------------------------------------------------------------------------------------------
// ==UserScript==
// @name           Kolorator podobnych raportów i wiadomości
// @namespace      http://code.google.com/p/plemiona-skrypty/
// @description    Kolorator podobnych raportów i wiadomości
// @version        2.0
// @license        Creative Commons 2.0 BY-NC-SA (http://creativecommons.org/licenses/by-nc-sa/2.0/pl)
// @author         Lukasz032 (Plemions Ś7)
// @contributor    Lukasz032 (Plemiona Ś7)
// @include        http://pl*.plemiona.pl/*screen=report*
// @include        http://pl*.plemiona.pl/*screen=mail*
// @include        http://pl*.plemiona.pl/*screen=settings*
// ==/UserScript==
// ------------------------------------------------------------------------------------------------------------------------

//
// Deklaracje wstępne
//
if ((typeof unsafeWindow) == "undefined") {
  unsafeWindow = window;
}

function getElementsByClass(searchClass,node,tag) {
var classElements = new Array();
if ( node == null )
node = document;
if ( tag == null )
tag = '*';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
for (i = 0, j = 0; i < elsLen; i++) {
if ( pattern.test(els[i].className) ) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}

function getGameDoc() {
  	getdoc=window.document;
  	if(!getdoc.URL.match("game.php")){
  		for(zeilenNummer=0;zeilenNummer<window.frames.length;zeilenNummer++){
  			if(window.frames[zeilenNummer].document.URL.match("game.php")){
  				getdoc = window.frames[zeilenNummer].document;
	  		}
  		}
  	}
  	return getdoc;
}
var PA = false;
var doc = getGameDoc();
var swiat = doc.URL.match(/pl(\d+)\.plemiona\.pl/)[1];
try {
var tables = doc.getElementsByTagName('table');
     for (var i=0; i<tables.length; i++) {
        if ($('menu_row2').get('html').match(/villages.png/)) {
          PA = true;
        } else if (doc.getElementsByTagName("ul")[0].className=="menu nowrap quickbar") {
          PA = true;
        } else {
          PA = false;
        }
      }
} catch (evt) {};

// 
// Funkcje zapisu i odczytu ustawień
// GMS-To-Cookies-Elementary-2 by Staemmes-Anonim (Modyfikacja by Nexces & Lukasz032)
//
function readCookie() {
	eval('var reg = /'+"Kolorator_d"+'=(.*?)(?:;|$)/;');
		var value = document.cookie.match(reg);
		if (value) {
			var ret;
			switch (unescape(value[1])) {
				case 'true':
					ret = true;
					break;
				case 'false':
					ret = false;
					break;
				default:
					ret = unescape(value[1]);
			}
			return ret;
		}
};
function readSettings(number) {
  var settings = readCookie();
  if (settings != null) {
    setting = settings.split(",");
    for (i=0; i<setting.length; i++) {
      switch (setting[i]) {
				case 'true':
					setting[i] = true;
					break;
				case 'false':
					setting[i] = false;
					break;
			}
		}
		return setting[number];
  }
};
unsafeWindow.KoloratorStoreSettings = function KoloratorStoreSettings() {
   var sForm = document.forms[0].elements;
   var pre_settings = new Array();
   for (var i=0; i<sForm.length; i++) {
     if (sForm[i].name != '') {
	     if (sForm[i].value == '') {
         sForm[i].value = false;
		   };
	  	 if (sForm[i].type == 'checkbox') {
	  		 sForm[i].value = sForm[i].checked;
	  	 };
	  	 if (sForm[i].type == 'radio') {
         if (sForm[i].checked) {
           sForm[i].value = sForm[i].value;
         } else {
           sForm[i].name = null;
           sForm[i].value = null;
         }
       };
       if (sForm[i].name == "Kolorator_d_0") {
         var sett0 = sForm[i].value;
       };
       if (sForm[i].name == "Kolorator_d_1") {
         var sett1 = sForm[i].value;
       };
       if (sForm[i].name == "Kolorator_d_2") {
         var sett2 = sForm[i].value;
       };
	   }
	 }
  KoloratorSaveOptions(sett0, sett1, sett2);
  return false;
};
function KoloratorSaveOptions(sett0, sett1, sett2) {
  try {
    var settings = sett0 + "," + sett1 + "," + sett2;
    document.cookie = "Kolorator_d" + '=' + escape(settings) + '; expires=' + (new Date(2020, 12, 1)).toGMTString() + ';';
    
    alert("Ustawienia zapisane poprawnie. Możesz wrócić do gry.");
    window.location = "http://pl" + swiat + ".plemiona.pl/staemme.php?screen=report";
    return true;
  } catch (evt) {
    alert("Wystąpił problem przy zapisie ustawień!\n\nDEBUG MODE:\n" + evt);
    return false;
  }
};

//
// Konfiguracja skryptu w trybie GUI
//
function settingsIncompleteWarn() {
  if (((readSettings("1") == undefined) || (readSettings("2") == undefined) || (readSettings("1") == null) || (readSettings("2") == null)) && (document.URL.match(/screen=(?:report|mail)/))) {
    if (confirm("Uruchomiłeś właśnie dodatek \"Kolorator podobnych raportów i wiadomości\".\n\nPreferencje pracy dodatku oraz funkcje detekcji nie zostały jeszcze określone.\n\nKliknij OK, aby przejść do strony ustawień.")) {
      window.location = "http://pl" + swiat + ".plemiona.pl/staemme.php?screen=settings&mode=settings&fakeaction=scr2";
      return true;
    } else {
      return false;
    }
    return true;
  }
}; 

function addSettingsLink() {
  var tr = new Array();
	tr[0] = document.createElement("tr");
	tr[1] = document.createElement("tr");
	var th = new Array();
	th[0] = document.createElement("th");
	th[1] = document.createElement("th");
	var td = new Array();
	td[0] = document.createElement("td");
	td[1] = document.createElement("td");
	
	th[0].setAttribute("colspan", "2");
	th[0].innerHTML = "";
	td[0].setAttribute("style", "vertical-align:top;");
	
	td[0].setAttribute("colspan", "2");
  td[0].innerHTML = "<a href='http://pl" + swiat + ".plemiona.pl/staemme.php?screen=settings&mode=settings&fakeaction=scr2'>Kolorator podobnych raportów i wiadomości - zmiana parametrów.</a>";
	
	tr[0].appendChild(th[0]);
	tr[1].appendChild(td[0]);
	
	var maintable = getElementsByClass("main", document)[0];
	
  if (!maintable.innerHTML.match(/Czas produkcji jednostek/)) {maintable.getElementsByTagName("table")[2].appendChild(tr[0]);}  
  maintable.getElementsByTagName("table")[2].appendChild(tr[1]);
};

function createSettingsPage() {
  var PA = true;
  if (document.forms[0]) {
    var settingsSpace = document.forms[0].parentNode;
    settingsSpace.innerHTML = '';
    loadSettings(settingsSpace);
  }
}

function loadSettings (container) {
		if ((typeof container) == "undefined") {
			return;
		}

			//container.style.border = '1px red solid';
			container.style.width = '85%';
			if (readSettings("0") == true) {
			  var wlaczony = 'checked="checked"';
			} else {
        var wlaczony = '';
      };
      if (readSettings("1") == "report_type") {
			  var rtyp1 = 'checked="checked"';
			  var rtyp2 = '';
			  var rtyp3 = '';
			  var rtyp4 = '';
			} else if (readSettings("1") == "attacker") {
			  var rtyp1 = '';
			  var rtyp2 = 'checked="checked"';
			  var rtyp3 = '';
			  var rtyp4 = '';
			} else if (readSettings("1") == "target_village") {
			  var rtyp1 = '';
			  var rtyp2 = '';
			  var rtyp3 = 'checked="checked"';
			  var rtyp4 = '';
			} else if (readSettings("1") == "combined") {
			  var rtyp1 = '';
			  var rtyp2 = '';
			  var rtyp3 = '';
			  var rtyp4 = 'checked="checked"';
			} else {
			  var rtyp1 = '';
			  var rtyp2 = '';
			  var rtyp3 = '';
			  var rtyp4 = 'checked="checked"';
			};
			if (readSettings("2") == "author") {
			  var wtyp1 = 'checked="checked"';
			  var wtyp2 = '';
			  var wtyp3 = '';
			} else if (readSettings("2") == "topic") {
			  var wtyp1 = '';
			  var wtyp2 = 'checked="checked"';
			  var wtyp3 = '';
			} else if (readSettings("2") == "combined") {
			  var wtyp1 = '';
			  var wtyp2 = '';
			  var wtyp3 = 'checked="checked"';
			} else {
			  var wtyp1 = 'checked="checked"';
			  var wtyp2 = '';
			  var wtyp3 = '';
			}; 
			var settingsForm = ' \
				<h3><i>Kolorator podobnych raportów i wiadomości</i> - Ustawienia</h3> \
				<p align="left"><font color="#6DE377"><i>by <b>Lukasz032</b></i> &#166; Wersja skryptu: <b>2.0</b> &#166; <i>Menu ustawień by <b>Lukasz032</b></i></font></p> \
				<form name="Kolorator_set" onsubmit="return KoloratorStoreSettings()" action="/game.php?screen=settings&amp;mode=settings"> \
					<table class="vis" width="100%"> \
						<tr><th colspan="2">Uruchomienie funkcji skryptu</th></tr> \
						<tr> \
							<td><label for="wlaczSkrypt">Włącz kolorowanie podobnych raportów&#92;wiadomości:</label></td> \
							<td> \
               <input type="checkbox" id="wlaczSkrypt" name="Kolorator_d_0" value="true" ' + wlaczony + '/> \
              </td> \
						</tr> \
						<tr><td colspan="2" style="background-color: transparent">&nbsp;</td></tr> \
						<tr><th colspan="2">Ustawienia poszczególnych akcji kolorowania</th></tr> \
						<tr> \
							<td><span title="W tym miejscu ustawia się sposób kolorowania (metodę detekcji) przy przeglądaniu raportów.">Funkcje kolorowania raportów*:</span></td> \
							<td> \
               <input type="radio" id="reportColorSwitchType" name="Kolorator_d_1" value="report_type" solidvalue="report_type" ' + rtyp1 + '/><label for="reportColorSwitchType">Typ raportu</label><br> \
							 <input type="radio" id="reportColorSwitchAttacker" name="Kolorator_d_1" value="attacker" solidvalue="attacker" ' + rtyp2 + '/><label for="reportColorSwitchAttacker">Atakujący</label><br> \
							 <input type="radio" id="reportColorSwitchTarget" name="Kolorator_d_1" value="target_village" solidvalue="target_village" ' + rtyp3 + '/><label for="reportColorSwitchTarget">Wioska docelowa</label><br> \
							 <input type="radio" id="reportColorSwitchCombined" name="Kolorator_d_1" value="combined" solidvalue="combined" ' + rtyp4 + '/><label for="reportColorSwitchCombined"><span title="Rozróżnianie wszystkich poprzednich czynników podczas doboru koloru.">Kombinowany*</span></label> \
             </td> \
						</tr> \
						<tr> \
							<td><span title="W tym miejscu ustawia się sposób kolorowania (metodę detekcji) przy przeglądaniu wiadomości.">Funkcje kolorowania wiadomości*:</span></td> \
							<td> \
               <input type="radio" id="messageColorSwitchAuthor" name="Kolorator_d_2" value="author" solidvalue="author" ' + wtyp1 + '/><label for="messageColorSwitchAuthor">Autor wiadomości</label><br> \
							 <input type="radio" id="messageColorSwitchTopic" name="Kolorator_d_2" value="topic" solidvalue="topic" ' + wtyp2 + '/><label for="messageColorSwitchTopic">Temat wiadomości</label><br> \
							 <input type="radio" id="messageColorSwitchCombined" name="Kolorator_d_2" value="combined" solidvalue="combined" ' + wtyp3 + '/><label for="messageColorSwitchCombined"><span title="Rozróżnianie wszystkich poprzednich czynników podczas doboru koloru.">Kombinowany*</span></label> \
             </td> \
						</tr> \
						<tr><td colspan="2" style="background-color: transparent">&nbsp;</td></tr> \
						\
						<tr><td colspan="2" style="background-color: transparent"></td></tr> \
						<tr><td colspan="2"><input type="submit" value="Zapisz ustawienia" /></td></tr> \
						<tr><td colspan="2" style="background-color: transparent"</td></tr> \
						<tr><td colspan="2"><em>*)&nbsp;Opcje&nbsp;oznaczone&nbsp;gwiazdką&nbsp;posiadają&nbsp;odpowiedzi.</em>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr> \
					</table> \
				</form> \
			';
			container.innerHTML = settingsForm;
			//return;
};

//
// Funkcja kolorowania raportów
//
function start_coloring_r() {
 try {
  var doc = getGameDoc();
  var tabela_prep = getElementsByClass("vis", doc);
  var tabela = tabela_prep[tabela_prep.length - 2];
  var color_palette = new Array(
    "#4083DA", "#558ACB", "#6692C4", "#8486C1", "#6EA872", "#4DCA2C", "#779FA6", "#769CC0", "#8597BE", "#9093BE", "#81AE7C", "#7EA5B8", 
    "#81A7A7", "#939FBC", "#94A3A6", "#6CCC3F", "#A09CB9", "#8EA9BF", "#9CA6BA", "#94B585", "#8DB59E", "#A5A9B8", "#99B0BB", "#A7AFA8", 
    "#A1B5A9", "#97B9B7", "#B5ADB5", "#ACB2B7", "#A7B7B9", "#94D453", "#AEBA9F", "#BEAEB8", "#AEBE8F", "#B4B7A7", "#BAC375", "#99D869", 
    "#C4B99A", "#B8BBB4", "#C4B5B5", "#BFB8B3", "#A7C5B2", "#BEBCA4", "#88E377", "#A0D77A", "#C2C19C", "#B3D276", "#B6C5B8", "#ADD86C", 
    "#C9BEB1", "#C3C3B4", "#B7DB5E", "#7BF57D", "#CCC799", "#B9DE53", "#BDD770", "#CEC893", "#C5CD95", "#B6FAE0", "#DBBEAD", "#C2CBB0", 
    "#C3D47E", "#D7C59A", "#CCD178", "#D1C6A6", "#D2CD82", "#D2CD82", "#C7D18E", "#D6C6A1", "#E0C0A6", "#D1D271", "#CBDD47", "#A5E295", 
    "#D5C6B0", "#D2C9AF", "#CFD962", "#D1E28B", "#E8DF5F", "#EBE347", "#E7DD73", "#D4DF9D", "#E4D79D", "#E9DF67", "#EAE255", "#E7D5A3", 
    "#DFD8A9", "#EADE6D", "#E8D898", "#E9D992", "#F1E059", "#E8DC87", "#EBD79F", "#CFE1B6", "#CFED77", "#F0D59F", "#DFDF9E", "#F1DD8A", 
    "#E1DEB5", "#E9E677", "#EAE292", "#D6E981", "#EDDB8E", "#ECDE83", "#EDDF7D", "#F4E277", "#E5DFB0", "#E8E298", "#E8E0AB", "#DCE5B2", 
    "#E8E2A4", "#E9F279", "#E9EE97", "#E4ECB3", "#EDF290", "#F2ECAF", "#EBF2AE"
  );
  var type = readSettings("1");
  var wiersze = tabela.getElementsByTagName("tr");
  if (type === "report_type") {
   var attack_color = Math.floor (Math.random() * color_palette.length);
   var help_color = Math.floor (Math.random() * color_palette.length);
   var transport_color = Math.floor (Math.random() * color_palette.length);
   var invite_color = Math.floor (Math.random() * color_palette.length);
   var helpdef_color = Math.floor (Math.random() * color_palette.length);
   var premium_color = Math.floor (Math.random() * color_palette.length);
   var allyact_color = Math.floor (Math.random() * color_palette.length);
   var zastepstwo_color = Math.floor (Math.random() * color_palette.length);
   for (a = 1; a < wiersze.length - 1; a++) {
     var text = wiersze[a].getElementsByTagName("td")[0].getElementsByTagName("span")[0].getElementsByTagName("span")[0].innerHTML;
     if (text.match(/atakuje/)) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack_color]);
     } else if ((text.match(/Wsparcie/)) || (text.match(/wycofuje/)) || (text.match(/odsyła/))) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[help_color]);
     } else if (text.match(/Transport/)) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport_color]);
     } else if ((text.match(/zaprosił/)) || (text.match(/Zaproszenie/))) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[invite_color]);
     } else if (text.match(/zostało zaatakowane/)) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helpdef_color]);
     } else if ((text === "Gratisowe konto Premium") || (text === "Konto Premium wkrótce się kończy")) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[premium_color]);
     } else if ((text.match(/wyproszony/)) || (text.match(/rozwiązał/))) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[allyact_color]);
     } else if (text.match(/zastępstwo/)) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[zastepstwo_color]);
     } else {
       var inne_color = Math.floor (Math.random() * color_palette.length);
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[inne_color]);
     };
   }
  } else if (type === "attacker") {
    var attack1_color = Math.floor (Math.random() * color_palette.length);
    var attack2_color = Math.floor (Math.random() * color_palette.length);
    var attack3_color = Math.floor (Math.random() * color_palette.length);
    var attack4_color = Math.floor (Math.random() * color_palette.length);
    var attack5_color = Math.floor (Math.random() * color_palette.length);
    var attack6_color = Math.floor (Math.random() * color_palette.length);
    var attack7_color = Math.floor (Math.random() * color_palette.length);
    var attack8_color = Math.floor (Math.random() * color_palette.length);
    var attack9_color = Math.floor (Math.random() * color_palette.length);
    var attack10_color = Math.floor (Math.random() * color_palette.length);
    var attack11_color = Math.floor (Math.random() * color_palette.length);
    var attack12_color = Math.floor (Math.random() * color_palette.length);
    for (a = 1; a < wiersze.length - 1; a++) {
     var text = wiersze[a].getElementsByTagName("td")[0].getElementsByTagName("span")[0].getElementsByTagName("span")[0].innerHTML;
     if ((text.match(/atakuje/)) || (text.match(/Wsparcie/)) || (text.match(/wycofuje/)) || (text.match(/odsyła/))) {
       if (text.match(/atakuje/)) {var attacker = text.match(/(.{0,30}) \(/)[1];}
       else if (text.match(/Wsparcie/)) {var attacker = text.match(/z (.{0,32}) dla gracza/)[1];}
       else if (text.match(/wycofuje/)) {var attacker = text.match(/(.{0,30}) wycofuje/)[1];}
       else if (text.match(/odsyła/)) {var attacker = text.match(/(.{0,30}) odsyła/)[1];}
         if ((attacker1) && (attacker == attacker1)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack1_color]);continue;}
         else if ((attacker2) && (attacker == attacker2)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack2_color]);continue;}
         else if ((attacker3) && (attacker == attacker3)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack3_color]);continue;}
         else if ((attacker4) && (attacker == attacker4)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack4_color]);continue;}
         else if ((attacker5) && (attacker == attacker5)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack5_color]);continue;}
         else if ((attacker6) && (attacker == attacker6)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack6_color]);continue;}
         else if ((attacker7) && (attacker == attacker7)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack7_color]);continue;}
         else if ((attacker8) && (attacker == attacker8)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack8_color]);continue;}
         else if ((attacker9) && (attacker == attacker9)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack9_color]);continue;}
         else if ((attacker10) && (attacker == attacker10)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack10_color]);continue;}
         else if ((attacker11) && (attacker == attacker11)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack11_color]);continue;}
         else if ((attacker12) && (attacker == attacker12)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack12_color]);continue;}
         else {
           if (attacker11) {
             var attacker12 = attacker;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack12_color]);
           } else if (attacker10) {
             var attacker11 = attacker;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack11_color]);
           } else if (attacker9) {
             var attacker10 = attacker;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack10_color]);
           } else if (attacker8) {
             var attacker9 = attacker;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack9_color]);
           } else if (attacker7) {
             var attacker8 = attacker;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack8_color]);
           } else if (attacker6) {
             var attacker7 = attacker;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack7_color]);
           } else if (attacker5) {
             var attacker6 = attacker;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack6_color]);
           } else if (attacker4) {
             var attacker5 = attacker;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack5_color]);
           } else if (attacker3) {
             var attacker4 = attacker;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack4_color]);
           } else if (attacker2) {
             var attacker3 = attacker;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack3_color]);
           } else if (attacker1) {
             var attacker2 = attacker;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack2_color]);
           } else {
             var attacker1 = attacker;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack1_color]);
           }
         }
     } else {
       var other_color = Math.floor (Math.random() * color_palette.length);
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[other_color]);
     }
    };
  } else if (type === "target_village") {
    var target1_color = Math.floor (Math.random() * color_palette.length);
    var target2_color = Math.floor (Math.random() * color_palette.length);
    var target3_color = Math.floor (Math.random() * color_palette.length);
    var target4_color = Math.floor (Math.random() * color_palette.length);
    var target5_color = Math.floor (Math.random() * color_palette.length);
    var target6_color = Math.floor (Math.random() * color_palette.length);
    var target7_color = Math.floor (Math.random() * color_palette.length);
    var target8_color = Math.floor (Math.random() * color_palette.length);
    var target9_color = Math.floor (Math.random() * color_palette.length);
    var target10_color = Math.floor (Math.random() * color_palette.length);
    var target11_color = Math.floor (Math.random() * color_palette.length);
    var target12_color = Math.floor (Math.random() * color_palette.length);
    var target13_color = Math.floor (Math.random() * color_palette.length);
    var target14_color = Math.floor (Math.random() * color_palette.length);
    var target15_color = Math.floor (Math.random() * color_palette.length);
    var target16_color = Math.floor (Math.random() * color_palette.length);
    var target17_color = Math.floor (Math.random() * color_palette.length);
    var target18_color = Math.floor (Math.random() * color_palette.length);
    var target19_color = Math.floor (Math.random() * color_palette.length);
    var target20_color = Math.floor (Math.random() * color_palette.length);
    for (a = 1; a < wiersze.length - 1; a++) {
     var text = wiersze[a].getElementsByTagName("td")[0].getElementsByTagName("span")[0].getElementsByTagName("span")[0].innerHTML;
     if ((text.match(/atakuje/)) || (text.match(/wspiera/)) || (text.match(/wsparcie/gi)) || (text.match(/Transport/))) {
       if (text.match(/atakuje/)) {
         var target_vlg = text.match(/atakuje (.{0,32}) \(/)[1];
       } else if (text.match(/Wsparcie.*dla gracza/)) {
         var target_vlg = text.match(/Wsparcie z (.{0,32}) dla gracza/)[1];
       } else if (text.match(/Wsparcie.*zaatakowane/)) {
         var target_vlg = text.match(/z ([^(\(\d{0,3}\|\d{0,3}\))][^K\d\d]) zostało zaatakowane/)[1];
       } else if ((text.match(/wycofuje/)) || (text.match(/odsyła/))) {
         var target_vlg = text.match(/(?:pomoc|wsparcie) z (.{0,32})/)[1]
       } else if (text.match(/Transport/)) {
         var target_vlg = text.match(/do ([^(\(\d{0,3}\|\d{0,3}\))][^K\d\d])/)[1];
       }
         if ((target1) && (target_vlg == target1)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target1_color]);continue;}
         else if ((target2) && (target_vlg == target2)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target2_color]);continue;}
         else if ((target3) && (target_vlg == target3)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target3_color]);continue;}
         else if ((target4) && (target_vlg == target4)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target4_color]);continue;}
         else if ((target5) && (target_vlg == target5)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target5_color]);continue;}
         else if ((target6) && (target_vlg == target6)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target6_color]);continue;}
         else if ((target7) && (target_vlg == target7)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target7_color]);continue;}
         else if ((target8) && (target_vlg == target8)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target8_color]);continue;}
         else if ((target9) && (target_vlg == target9)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target9_color]);continue;}
         else if ((target10) && (target_vlg == target10)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target10_color]);continue;}
         else if ((target11) && (target_vlg == target11)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target11_color]);continue;}
         else if ((target12) && (target_vlg == target12)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target12_color]);continue;}
         else if ((target13) && (target_vlg == target13)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target13_color]);continue;}
         else if ((target14) && (target_vlg == target14)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target14_color]);continue;}
         else if ((target15) && (target_vlg == target15)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target15_color]);continue;}
         else if ((target16) && (target_vlg == target16)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target16_color]);continue;}
         else if ((target17) && (target_vlg == target17)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target17_color]);continue;}
         else if ((target18) && (target_vlg == target18)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target18_color]);continue;}
         else if ((target19) && (target_vlg == target19)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target19_color]);continue;}
         else if ((target20) && (target_vlg == target20)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target20_color]);continue;}
         else {
           if (target19) {
             var target20 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target20_color]);
           } else if (target18) {
             var target19 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target19_color]);
           } else if (target17) {
             var target18 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target18_color]);
           } else if (target16) {
             var target17 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target17_color]);
           } else if (target15) {
             var target16 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target16_color]);
           } else if (target14) {
             var target15 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target15_color]);
           } else if (target13) {
             var target14 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target14_color]);
           } else if (target12) {
             var target13 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target13_color]);
           } else if (target11) {
             var target12 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target12_color]);
           } else if (target10) {
             var target11 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target11_color]);
           } else if (target9) {
             var target10 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target10_color]);
           } else if (target8) {
             var target9 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target9_color]);
           } else if (target7) {
             var target8 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target8_color]);
           } else if (target6) {
             var target7 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target7_color]);
           } else if (target5) {
             var target6 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target6_color]);
           } else if (target4) {
             var target5 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target5_color]);
           } else if (target3) {
             var target4 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target4_color]);
           } else if (target2) {
             var target3 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target3_color]);
           } else if (target1) {
             var target2 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target2_color]);
           } else {
             var target1 = target_vlg;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[target1_color]);
           }
         }
     } else {
       var other_color = Math.floor (Math.random() * color_palette.length);
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[other_color]);
     }
    };
  } else if (type === "combined") {
   var attack1_color = Math.floor (Math.random() * color_palette.length);
   var attack2_color = Math.floor (Math.random() * color_palette.length);
   var attack3_color = Math.floor (Math.random() * color_palette.length);
   var attack4_color = Math.floor (Math.random() * color_palette.length);
   var attack5_color = Math.floor (Math.random() * color_palette.length);
   var attack6_color = Math.floor (Math.random() * color_palette.length);
   var attack7_color = Math.floor (Math.random() * color_palette.length);
   var attack8_color = Math.floor (Math.random() * color_palette.length);
   var attack9_color = Math.floor (Math.random() * color_palette.length);
   var attack10_color = Math.floor (Math.random() * color_palette.length);
   var attack11_color = Math.floor (Math.random() * color_palette.length);
   var attack12_color = Math.floor (Math.random() * color_palette.length);
   var helper1_color = Math.floor (Math.random() * color_palette.length);
   var helper2_color = Math.floor (Math.random() * color_palette.length);
   var helper3_color = Math.floor (Math.random() * color_palette.length);
   var helper4_color = Math.floor (Math.random() * color_palette.length);
   var helper5_color = Math.floor (Math.random() * color_palette.length);
   var helper6_color = Math.floor (Math.random() * color_palette.length);
   var helper7_color = Math.floor (Math.random() * color_palette.length);
   var helper8_color = Math.floor (Math.random() * color_palette.length);
   var helper9_color = Math.floor (Math.random() * color_palette.length);
   var helper10_color = Math.floor (Math.random() * color_palette.length);
   var helper11_color = Math.floor (Math.random() * color_palette.length);
   var helper12_color = Math.floor (Math.random() * color_palette.length);
   var transport1_color = Math.floor (Math.random() * color_palette.length);
   var transport2_color = Math.floor (Math.random() * color_palette.length);
   var transport3_color = Math.floor (Math.random() * color_palette.length);
   var transport4_color = Math.floor (Math.random() * color_palette.length);
   var transport5_color = Math.floor (Math.random() * color_palette.length);
   var transport6_color = Math.floor (Math.random() * color_palette.length);
   var transport7_color = Math.floor (Math.random() * color_palette.length);
   var transport8_color = Math.floor (Math.random() * color_palette.length);
   var transport9_color = Math.floor (Math.random() * color_palette.length);
   var transport10_color = Math.floor (Math.random() * color_palette.length);
   var transport11_color = Math.floor (Math.random() * color_palette.length);
   var transport12_color = Math.floor (Math.random() * color_palette.length);
   var invite_color = Math.floor (Math.random() * color_palette.length);
   var helpdef_color = Math.floor (Math.random() * color_palette.length);
   var premium_color = Math.floor (Math.random() * color_palette.length);
   var allyact_color = Math.floor (Math.random() * color_palette.length);
   var zastepstwo_color = Math.floor (Math.random() * color_palette.length);
   var others_color = Math.floor (Math.random() * color_palette.length);
   for (a = 1; a < wiersze.length - 1; a++) {
     var text = wiersze[a].getElementsByTagName("td")[0].getElementsByTagName("span")[0].getElementsByTagName("span")[0].innerHTML;
     if (text.match(/atakuje/)) {
       var provoder = text.match(/(.{0,30}) \(/)[1];
       if ((attacker1) && (provoder == attacker1)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack1_color]);continue;}
         else if ((attacker2) && (provoder == attacker2)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack2_color]);continue;}
         else if ((attacker3) && (provoder == attacker3)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack3_color]);continue;}
         else if ((attacker4) && (provoder == attacker4)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack4_color]);continue;}
         else if ((attacker5) && (provoder == attacker5)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack5_color]);continue;}
         else if ((attacker6) && (provoder == attacker6)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack6_color]);continue;}
         else if ((attacker7) && (provoder == attacker7)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack7_color]);continue;}
         else if ((attacker8) && (provoder == attacker8)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack8_color]);continue;}
         else if ((attacker9) && (provoder == attacker9)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack9_color]);continue;}
         else if ((attacker10) && (provoder == attacker10)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack10_color]);continue;}
         else if ((attacker11) && (provoder == attacker11)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack11_color]);continue;}
         else if ((attacker12) && (provoder == attacker12)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack12_color]);continue;}
         else {
           if (attacker11) {
             var attacker12 = provoder;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack12_color]);
           } else if (attacker10) {
             var attacker11 = provoder;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack11_color]);
           } else if (attacker9) {
             var attacker10 = provoder;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack10_color]);
           } else if (attacker8) {
             var attacker9 = provoder;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack9_color]);
           } else if (attacker7) {
             var attacker8 = provoder;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack8_color]);
           } else if (attacker6) {
             var attacker7 = provoder;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack7_color]);
           } else if (attacker5) {
             var attacker6 = provoder;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack6_color]);
           } else if (attacker4) {
             var attacker5 = provoder;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack5_color]);
           } else if (attacker3) {
             var attacker4 = provoder;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack4_color]);
           } else if (attacker2) {
             var attacker3 = provoder;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack3_color]);
           } else if (attacker1) {
             var attacker2 = provoder;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack2_color]);
           } else {
             var attacker1 = provoder;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack1_color]);
           }
         }
     } else if ((text.match(/Wsparcie/)) || (text.match(/wycofuje/)) || (text.match(/odsyła/))) {
       if (text.match(/Wsparcie/)) {var helper = text.match(/z (.{0,32}) dla gracza/)[1];}
       else if (text.match(/wycofuje/)) {var helper = text.match(/(.{0,30}) wycofuje/)[1];}
       else if (text.match(/odsyła/)) {var helper = text.match(/(.{0,30}) odsyła/)[1];}
       if ((helper1) && (helper == helper1)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper1_color]);continue;}
         else if ((helper2) && (helper == helper2)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper2_color]);continue;}
         else if ((helper3) && (helper == helper3)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper3_color]);continue;}
         else if ((helper4) && (helper == helper4)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper4_color]);continue;}
         else if ((helper5) && (helper == helper5)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper5_color]);continue;}
         else if ((helper6) && (helper == helper6)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper6_color]);continue;}
         else if ((helper7) && (helper == helper7)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper7_color]);continue;}
         else if ((helper8) && (helper == helper8)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper8_color]);continue;}
         else if ((helper9) && (helper == helper9)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper9_color]);continue;}
         else if ((helper10) && (helper == helper10)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper10_color]);continue;}
         else if ((helper11) && (helper == helper11)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper11_color]);continue;}
         else if ((helper12) && (helper == helper12)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper12_color]);continue;}
         else {
           if (helper11) {
             var helper12 = helper;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper12_color]);
           } else if (helper10) {
             var helper11 = helper;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper11_color]);
           } else if (helper9) {
             var helper10 = helper;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper10_color]);
           } else if (helper8) {
             var helper9 = helper;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper9_color]);
           } else if (helper7) {
             var helper8 = helper;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper8_color]);
           } else if (helper6) {
             var helper7 = helper;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper7_color]);
           } else if (helper5) {
             var helper6 = helper;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper6_color]);
           } else if (helper4) {
             var helper5 = helper;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper5_color]);
           } else if (helper3) {
             var helper4 = helper;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper4_color]);
           } else if (helper2) {
             var helper3 = helper;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper3_color]);
           } else if (helper1) {
             var helper2 = helper;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper2_color]);
           } else {
             var helper1 = helper;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helper1_color]);
           }
         }
     } else if (text.match(/Transport/)) {
       var transporter = text.match(/do ([^(\(\d{0,3}\|\d{0,3}\))][^K\d\d])/)[1];
       if ((transport1) && (transporter == transport1)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport1_color]);continue;}
         else if ((transport2) && (transporter == transport2)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport2_color]);continue;}
         else if ((transport3) && (transporter == transport3)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport3_color]);continue;}
         else if ((transport4) && (transporter == transport4)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport4_color]);continue;}
         else if ((transport5) && (transporter == transport5)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport5_color]);continue;}
         else if ((transport6) && (transporter == transport6)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport6_color]);continue;}
         else if ((transport7) && (transporter == transport7)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport7_color]);continue;}
         else if ((transport8) && (transporter == transport8)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport8_color]);continue;}
         else if ((transport9) && (transporter == transport9)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport9_color]);continue;}
         else if ((transport10) && (transporter == transport10)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport10_color]);continue;}
         else if ((transport11) && (transporter == transport11)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport11_color]);continue;}
         else if ((transport12) && (transporter == transport12)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport12_color]);continue;}
         else {
           if (transport11) {
             var transport12 = transporter;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport12_color]);
           } else if (transport10) {
             var transport11 = transporter;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport11_color]);
           } else if (transport9) {
             var transport10 = transporter;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport10_color]);
           } else if (transport8) {
             var transport9 = transporter;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport9_color]);
           } else if (transport7) {
             var transport8 = transporter;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport8_color]);
           } else if (transport6) {
             var transport7 = transporter;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport7_color]);
           } else if (transport5) {
             var transport6 = transporter;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport6_color]);
           } else if (transport4) {
             var transport5 = transporter;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport5_color]);
           } else if (transport3) {
             var transport4 = transporter;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport4_color]);
           } else if (transport2) {
             var transport3 = transporter;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport3_color]);
           } else if (transport1) {
             var transport2 = transporter;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport2_color]);
           } else {
             var transport1 = transporter;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[transport1_color]);
           }
         }
     } else if ((text.match(/zaprosił/)) || (text.match(/Zaproszenie/))) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[invite_color]);
     } else if (text.match(/zostało zaatakowane/)) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[helpdef_color]);
     } else if ((text === "Gratisowe konto Premium") || (text === "Konto Premium wkrótce się kończy")) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[premium_color]);
     } else if ((text.match(/wyproszony/)) || (text.match(/rozwiązał/))) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[allyact_color]);
     } else if (text.match(/zastępstwo/)) {     
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[zastepstwo_color]);
     } else {
       wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[others_color]);
     }
   }
  }
 } catch (evt) {};
};

//
// Funkcja kolorowania wiadomości
//
function start_coloring_w() {
  var tabela_prep = getElementsByClass("vis", document);
  var tabela = tabela_prep[tabela_prep.length - 2];
//  alert(tabela.innerHTML);
  var color_palette = new Array(
    "#4083DA", "#558ACB", "#6692C4", "#8486C1", "#6EA872", "#4DCA2C", "#779FA6", "#769CC0", "#8597BE", "#9093BE", "#81AE7C", "#7EA5B8", 
    "#81A7A7", "#939FBC", "#94A3A6", "#6CCC3F", "#A09CB9", "#8EA9BF", "#9CA6BA", "#94B585", "#8DB59E", "#A5A9B8", "#99B0BB", "#A7AFA8", 
    "#A1B5A9", "#97B9B7", "#B5ADB5", "#ACB2B7", "#A7B7B9", "#94D453", "#AEBA9F", "#BEAEB8", "#AEBE8F", "#B4B7A7", "#BAC375", "#99D869", 
    "#C4B99A", "#B8BBB4", "#C4B5B5", "#BFB8B3", "#A7C5B2", "#BEBCA4", "#88E377", "#A0D77A", "#C2C19C", "#B3D276", "#B6C5B8", "#ADD86C", 
    "#C9BEB1", "#C3C3B4", "#B7DB5E", "#7BF57D", "#CCC799", "#B9DE53", "#BDD770", "#CEC893", "#C5CD95", "#B6FAE0", "#DBBEAD", "#C2CBB0", 
    "#C3D47E", "#D7C59A", "#CCD178", "#D1C6A6", "#D2CD82", "#D2CD82", "#C7D18E", "#D6C6A1", "#E0C0A6", "#D1D271", "#CBDD47", "#A5E295", 
    "#D5C6B0", "#D2C9AF", "#CFD962", "#D1E28B", "#E8DF5F", "#EBE347", "#E7DD73", "#D4DF9D", "#E4D79D", "#E9DF67", "#EAE255", "#E7D5A3", 
    "#DFD8A9", "#EADE6D", "#E8D898", "#E9D992", "#F1E059", "#E8DC87", "#EBD79F", "#CFE1B6", "#CFED77", "#F0D59F", "#DFDF9E", "#F1DD8A", 
    "#E1DEB5", "#E9E677", "#EAE292", "#D6E981", "#EDDB8E", "#ECDE83", "#EDDF7D", "#F4E277", "#E5DFB0", "#E8E298", "#E8E0AB", "#DCE5B2", 
    "#E8E2A4", "#E9F279", "#E9EE97", "#E4ECB3", "#EDF290", "#F2ECAF", "#EBF2AE"
  );
  var type = readSettings("2");
  var wiersze = tabela.getElementsByTagName("tr");
  if (type === "author") {
   var attack1_color = Math.floor (Math.random() * color_palette.length);
   var attack2_color = Math.floor (Math.random() * color_palette.length);
   var attack3_color = Math.floor (Math.random() * color_palette.length);
   var attack4_color = Math.floor (Math.random() * color_palette.length);
   var attack5_color = Math.floor (Math.random() * color_palette.length);
   var attack6_color = Math.floor (Math.random() * color_palette.length);
   var attack7_color = Math.floor (Math.random() * color_palette.length);
   var attack8_color = Math.floor (Math.random() * color_palette.length);
   var attack9_color = Math.floor (Math.random() * color_palette.length);
   var attack10_color = Math.floor (Math.random() * color_palette.length);
   var attack11_color = Math.floor (Math.random() * color_palette.length);
   var attack12_color = Math.floor (Math.random() * color_palette.length);
   var attack13_color = Math.floor (Math.random() * color_palette.length);
   var attack14_color = Math.floor (Math.random() * color_palette.length);
   var attack15_color = Math.floor (Math.random() * color_palette.length);
   var attack16_color = Math.floor (Math.random() * color_palette.length);
   var attack17_color = Math.floor (Math.random() * color_palette.length);
   var attack18_color = Math.floor (Math.random() * color_palette.length);
   var attack19_color = Math.floor (Math.random() * color_palette.length);
   var attack20_color = Math.floor (Math.random() * color_palette.length);
   if(navigator.appVersion.indexOf("MSIE")>-1) {document.getElementById("filter").outerHTML = "";} 
   else {document.getElementById("filter").innerHTML = "";}
   for (a = 1; a < wiersze.length - 1; a++) {
     var author = wiersze[a].getElementsByTagName("td")[1].innerHTML.replace(/<img.+?>/, "").replace(/\s+?(<a|Plem)/, "$1");
       if ((attacker1) && (author == attacker1)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack1_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack1_color]);continue;}
         else if ((attacker2) && (author == attacker2)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack2_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack2_color]);continue;}
         else if ((attacker3) && (author == attacker3)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack3_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack3_color]);continue;}
         else if ((attacker4) && (author == attacker4)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack4_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack4_color]);continue;}
         else if ((attacker5) && (author == attacker5)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack5_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack5_color]);continue;}
         else if ((attacker6) && (author == attacker6)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack6_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack6_color]);continue;}
         else if ((attacker7) && (author == attacker7)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack7_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack7_color]);continue;}
         else if ((attacker8) && (author == attacker8)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack8_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack8_color]);continue;}
         else if ((attacker9) && (author == attacker9)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack9_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack9_color]);continue;}
         else if ((attacker10) && (author == attacker10)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack10_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack10_color]);continue;}
         else if ((attacker11) && (author == attacker11)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack11_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack11_color]);continue;}
         else if ((attacker12) && (author == attacker12)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack12_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack12_color]);continue;}
         else if ((attacker13) && (author == attacker13)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack13_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack13_color]);continue;}
         else if ((attacker14) && (author == attacker14)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack14_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack14_color]);continue;}
         else if ((attacker15) && (author == attacker15)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack15_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack15_color]);continue;}
         else if ((attacker16) && (author == attacker16)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack16_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack16_color]);continue;}
         else if ((attacker17) && (author == attacker17)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack17_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack17_color]);continue;}
         else if ((attacker18) && (author == attacker18)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack18_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack18_color]);continue;}
         else if ((attacker19) && (author == attacker19)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack19_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack19_color]);continue;}
         else if ((attacker20) && (author == attacker20)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack20_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack20_color]);continue;}
         else {
           if (attacker19) {
             var attacker20 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack20_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack20_color]);
           } else if (attacker18) {
             var attacker19 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack19_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack19_color]);
           } else if (attacker17) {
             var attacker18 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack18_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack18_color]);
           } else if (attacker16) {
             var attacker17 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack17_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack17_color]);
           } else if (attacker15) {
             var attacker16 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack16_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack16_color]);
           } else if (attacker14) {
             var attacker15 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack15_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack15_color]);
           } else if (attacker13) {
             var attacker14 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack14_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack14_color]);
           } else if (attacker12) {
             var attacker13 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack13_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack13_color]);
           } else if (attacker11) {
             var attacker12 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack12_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack12_color]);
           } else if (attacker10) {
             var attacker11 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack11_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack11_color]);
           } else if (attacker9) {
             var attacker10 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack10_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack10_color]);
           } else if (attacker8) {
             var attacker9 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack9_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack9_color]);
           } else if (attacker7) {
             var attacker8 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack8_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack8_color]);
           } else if (attacker6) {
             var attacker7 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack7_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack7_color]);
           } else if (attacker5) {
             var attacker6 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack6_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack6_color]);
           } else if (attacker4) {
             var attacker5 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack5_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack5_color]);
           } else if (attacker3) {
             var attacker4 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack4_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack4_color]);
           } else if (attacker2) {
             var attacker3 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack3_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack3_color]);
           } else if (attacker1) {
             var attacker2 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack2_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack2_color]);
           } else {
             var attacker1 = author;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack1_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack1_color]);
           }
         }
   }
  } else if (type === "topic") {
   var attack1_color = Math.floor (Math.random() * color_palette.length);
   var attack2_color = Math.floor (Math.random() * color_palette.length);
   var attack3_color = Math.floor (Math.random() * color_palette.length);
   var attack4_color = Math.floor (Math.random() * color_palette.length);
   var attack5_color = Math.floor (Math.random() * color_palette.length);
   var attack6_color = Math.floor (Math.random() * color_palette.length);
   var attack7_color = Math.floor (Math.random() * color_palette.length);
   var attack8_color = Math.floor (Math.random() * color_palette.length);
   var attack9_color = Math.floor (Math.random() * color_palette.length);
   var attack10_color = Math.floor (Math.random() * color_palette.length);
   var attack11_color = Math.floor (Math.random() * color_palette.length);
   var attack12_color = Math.floor (Math.random() * color_palette.length);
   var attack13_color = Math.floor (Math.random() * color_palette.length);
   var attack14_color = Math.floor (Math.random() * color_palette.length);
   var attack15_color = Math.floor (Math.random() * color_palette.length);
   var attack16_color = Math.floor (Math.random() * color_palette.length);
   var attack17_color = Math.floor (Math.random() * color_palette.length);
   var attack18_color = Math.floor (Math.random() * color_palette.length);
   var attack19_color = Math.floor (Math.random() * color_palette.length);
   var attack20_color = Math.floor (Math.random() * color_palette.length);
   if(navigator.appVersion.indexOf("MSIE")>-1) {document.getElementById("filter").outerHTML = "";} 
   else {document.getElementById("filter").innerHTML = "";}
   for (a = 1; a < wiersze.length - 1; a++) {
     var topic = wiersze[a].getElementsByTagName("td")[0].innerHTML.replace(/<[^>]+>/gi, "").replace(/\s/gi, "");
       if ((attacker1) && (topic == attacker1)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack1_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack1_color]);continue;}
         else if ((attacker2) && (topic == attacker2)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack2_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack2_color]);continue;}
         else if ((attacker3) && (topic == attacker3)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack3_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack3_color]);continue;}
         else if ((attacker4) && (topic == attacker4)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack4_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack4_color]);continue;}
         else if ((attacker5) && (topic == attacker5)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack5_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack5_color]);continue;}
         else if ((attacker6) && (topic == attacker6)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack6_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack6_color]);continue;}
         else if ((attacker7) && (topic == attacker7)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack7_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack7_color]);continue;}
         else if ((attacker8) && (topic == attacker8)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack8_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack8_color]);continue;}
         else if ((attacker9) && (topic == attacker9)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack9_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack9_color]);continue;}
         else if ((attacker10) && (topic == attacker10)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack10_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack10_color]);continue;}
         else if ((attacker11) && (topic == attacker11)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack11_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack11_color]);continue;}
         else if ((attacker12) && (topic == attacker12)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack12_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack12_color]);continue;}
         else if ((attacker13) && (topic == attacker13)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack13_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack13_color]);continue;}
         else if ((attacker14) && (topic == attacker14)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack14_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack14_color]);continue;}
         else if ((attacker15) && (topic == attacker15)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack15_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack15_color]);continue;}
         else if ((attacker16) && (topic == attacker16)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack16_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack16_color]);continue;}
         else if ((attacker17) && (topic == attacker17)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack17_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack17_color]);continue;}
         else if ((attacker18) && (topic == attacker18)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack18_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack18_color]);continue;}
         else if ((attacker19) && (topic == attacker19)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack19_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack19_color]);continue;}
         else if ((attacker20) && (topic == attacker20)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack20_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack20_color]);continue;}
         else {
           if (attacker19) {
             var attacker20 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack20_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack20_color]);
           } else if (attacker18) {
             var attacker19 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack19_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack19_color]);
           } else if (attacker17) {
             var attacker18 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack18_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack18_color]);
           } else if (attacker16) {
             var attacker17 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack17_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack17_color]);
           } else if (attacker15) {
             var attacker16 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack16_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack16_color]);
           } else if (attacker14) {
             var attacker15 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack15_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack15_color]);
           } else if (attacker13) {
             var attacker14 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack14_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack14_color]);
           } else if (attacker12) {
             var attacker13 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack13_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack13_color]);
           } else if (attacker11) {
             var attacker12 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack12_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack12_color]);
           } else if (attacker10) {
             var attacker11 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack11_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack11_color]);
           } else if (attacker9) {
             var attacker10 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack10_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack10_color]);
           } else if (attacker8) {
             var attacker9 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack9_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack9_color]);
           } else if (attacker7) {
             var attacker8 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack8_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack8_color]);
           } else if (attacker6) {
             var attacker7 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack7_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack7_color]);
           } else if (attacker5) {
             var attacker6 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack6_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack6_color]);
           } else if (attacker4) {
             var attacker5 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack5_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack5_color]);
           } else if (attacker3) {
             var attacker4 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack4_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack4_color]);
           } else if (attacker2) {
             var attacker3 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack3_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack3_color]);
           } else if (attacker1) {
             var attacker2 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack2_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack2_color]);
           } else {
             var attacker1 = topic;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack1_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack1_color]);
           }
         }
   }
  } else if (type === "combined") {
   var attack1_color = Math.floor (Math.random() * color_palette.length);
   var attack2_color = Math.floor (Math.random() * color_palette.length);
   var attack3_color = Math.floor (Math.random() * color_palette.length);
   var attack4_color = Math.floor (Math.random() * color_palette.length);
   var attack5_color = Math.floor (Math.random() * color_palette.length);
   var attack6_color = Math.floor (Math.random() * color_palette.length);
   var attack7_color = Math.floor (Math.random() * color_palette.length);
   var attack8_color = Math.floor (Math.random() * color_palette.length);
   var attack9_color = Math.floor (Math.random() * color_palette.length);
   var attack10_color = Math.floor (Math.random() * color_palette.length);
   var attack11_color = Math.floor (Math.random() * color_palette.length);
   var attack12_color = Math.floor (Math.random() * color_palette.length);
   var attack13_color = Math.floor (Math.random() * color_palette.length);
   var attack14_color = Math.floor (Math.random() * color_palette.length);
   var attack15_color = Math.floor (Math.random() * color_palette.length);
   var attack16_color = Math.floor (Math.random() * color_palette.length);
   var attack17_color = Math.floor (Math.random() * color_palette.length);
   var attack18_color = Math.floor (Math.random() * color_palette.length);
   var attack19_color = Math.floor (Math.random() * color_palette.length);
   var attack20_color = Math.floor (Math.random() * color_palette.length);
   if(navigator.appVersion.indexOf("MSIE")>-1) {document.getElementById("filter").outerHTML = "";} 
   else {document.getElementById("filter").innerHTML = "";}
   for (a = 1; a < wiersze.length - 1; a++) {
     var author = wiersze[a].getElementsByTagName("td")[1].innerHTML.replace(/<img.+?>/, "").replace(/\s+?(<a|Plem)/, "$1");
     var topic = wiersze[a].getElementsByTagName("td")[0].innerHTML.replace(/<[^>]+>/gi, "").replace(/\s/gi, "");
     var string = author + "." + topic
       if ((attacker1) && (string == attacker1)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack1_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack1_color]);continue;}
         else if ((attacker2) && (string == attacker2)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack2_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack2_color]);continue;}
         else if ((attacker3) && (string == attacker3)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack3_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack3_color]);continue;}
         else if ((attacker4) && (string == attacker4)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack4_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack4_color]);continue;}
         else if ((attacker5) && (string == attacker5)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack5_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack5_color]);continue;}
         else if ((attacker6) && (string == attacker6)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack6_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack6_color]);continue;}
         else if ((attacker7) && (string == attacker7)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack7_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack7_color]);continue;}
         else if ((attacker8) && (string == attacker8)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack8_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack8_color]);continue;}
         else if ((attacker9) && (string == attacker9)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack9_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack9_color]);continue;}
         else if ((attacker10) && (string == attacker10)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack10_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack10_color]);continue;}
         else if ((attacker11) && (string == attacker11)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack11_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack11_color]);continue;}
         else if ((attacker12) && (string == attacker12)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack12_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack12_color]);continue;}
         else if ((attacker13) && (string == attacker13)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack13_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack13_color]);continue;}
         else if ((attacker14) && (string == attacker14)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack14_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack14_color]);continue;}
         else if ((attacker15) && (string == attacker15)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack15_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack15_color]);continue;}
         else if ((attacker16) && (string == attacker16)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack16_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack16_color]);continue;}
         else if ((attacker17) && (string == attacker17)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack17_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack17_color]);continue;}
         else if ((attacker18) && (string == attacker18)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack18_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack18_color]);continue;}
         else if ((attacker19) && (string == attacker19)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack19_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack19_color]);continue;}
         else if ((attacker20) && (string == attacker20)) {wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack20_color]);wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack20_color]);continue;}
         else {
           if (attacker19) {
             var attacker20 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack20_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack20_color]);
           } else if (attacker18) {
             var attacker19 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack19_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack19_color]);
           } else if (attacker17) {
             var attacker18 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack18_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack18_color]);
           } else if (attacker16) {
             var attacker17 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack17_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack17_color]);
           } else if (attacker15) {
             var attacker16 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack16_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack16_color]);
           } else if (attacker14) {
             var attacker15 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack15_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack15_color]);
           } else if (attacker13) {
             var attacker14 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack14_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack14_color]);
           } else if (attacker12) {
             var attacker13 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack13_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack13_color]);
           } else if (attacker11) {
             var attacker12 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack12_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack12_color]);
           } else if (attacker10) {
             var attacker11 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack11_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack11_color]);
           } else if (attacker9) {
             var attacker10 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack10_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack10_color]);
           } else if (attacker8) {
             var attacker9 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack9_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack9_color]);
           } else if (attacker7) {
             var attacker8 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack8_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack8_color]);
           } else if (attacker6) {
             var attacker7 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack7_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack7_color]);
           } else if (attacker5) {
             var attacker6 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack6_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack6_color]);
           } else if (attacker4) {
             var attacker5 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack5_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack5_color]);
           } else if (attacker3) {
             var attacker4 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack4_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack4_color]);
           } else if (attacker2) {
             var attacker3 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack3_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack3_color]);
           } else if (attacker1) {
             var attacker2 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack2_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack2_color]);
           } else {
             var attacker1 = string;
             wiersze[a].getElementsByTagName("td")[0].setAttribute("style","background-color:" + color_palette[attack1_color]);
             wiersze[a].getElementsByTagName("td")[1].setAttribute("style","background-color:" + color_palette[attack1_color]);
           }
         }
   }
  }
}

//
// Wykonanie skryptu na stronie
//
if (!document.URL.match(/intro/)) {
  settingsIncompleteWarn();
};
if ((PA == true) && (readSettings("0") == true)) {
  if (document.URL.match(/screen=report/)) {start_coloring_r();};
  if (document.URL.match(/screen=mail/)) {start_coloring_w();};
};
if (document.URL.match(/fakeaction=scr2/)) {
  createSettingsPage();
};
if ((document.URL.match(/screen=settings&mode=settings/)) && (!document.URL.match(/fakeaction=scr2/))) {
  addSettingsLink();
};
